package com.starlink.model.util;

import com.starlink.client.jd.request.base.Contact;
import com.starlink.model.domain.AdminAddressDO;
import com.starlink.model.dtomapper.AdminAdressDtoMapper;
import com.starlink.model.vo.AdminAddressVO;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhanghong
 */
public class AdminAddressConvert {

    public static List<AdminAddressVO> buildAdminAdressVoList(List<AdminAddressDO> adminAddressDOList) {
        if (CollectionUtils.isEmpty(adminAddressDOList)) {
            return Lists.newArrayList();
        }
        List<AdminAddressVO> adminAdressVOList = new ArrayList<>();
        for (AdminAddressDO adminAddressDO : adminAddressDOList) {
            adminAdressVOList.add(AdminAdressDtoMapper.INSTANCE.do2VO(adminAddressDO));
        }

        return adminAdressVOList;
    }

    public static Contact buildContact(AdminAddressDO adminAddress) {
        return Contact.builder()
                .fullAddress(adminAddress.getAddress())
                .mobile(adminAddress.getMobile())
                .name(adminAddress.getName())
                .build();
    }
}
